<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>数据库理论 | 课程简介</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../C02-Database/DistributedID.html" />
    
    
    <link rel="prev" href="../C02-Database/SQLAlchemyOperations.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2.5"
        data-chapter-title="数据库理论"
        data-filepath="C02-Database/DatabaseTheory.md"
        data-basepath=".."
        data-revision="Mon May 27 2019 03:35:45 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        课程简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="C01-Introduction/index.html">
            
                
                    <a href="../C01-Introduction/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        项目介绍
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="C01-Introduction/AboutToutiaoWebVM.html">
            
                
                    <a href="../C01-Introduction/AboutToutiaoWebVM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        ToutiaoWeb虚拟机使用说明
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="C01-Introduction/PycharmRemoteDevelop.html">
            
                
                    <a href="../C01-Introduction/PycharmRemoteDevelop.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        Pycharm远程开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="C01-Introduction/AboutProject.html">
            
                
                    <a href="../C01-Introduction/AboutProject.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        产品与开发
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="C02-Database/index.html">
            
                
                    <a href="../C02-Database/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        数据库
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="C02-Database/DatabaseDesign.html">
            
                
                    <a href="../C02-Database/DatabaseDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="C02-Database/ORM.html">
            
                
                    <a href="../C02-Database/ORM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        理解ORM
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="C02-Database/SQLAlchemyMapping.html">
            
                
                    <a href="../C02-Database/SQLAlchemyMapping.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        SQLAlchemy映射构建
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="C02-Database/SQLAlchemyOperations.html">
            
                
                    <a href="../C02-Database/SQLAlchemyOperations.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        SQLAlchemy操作
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.5" data-path="C02-Database/DatabaseTheory.html">
            
                
                    <a href="../C02-Database/DatabaseTheory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        数据库理论
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="C02-Database/DistributedID.html">
            
                
                    <a href="../C02-Database/DistributedID.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        分布式ID
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="C02-Database/DatabaseOptimize.html">
            
                
                    <a href="../C02-Database/DatabaseOptimize.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        数据库优化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="C02-Database/Redis.html">
            
                
                    <a href="../C02-Database/Redis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        Redis
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="C03-Gitflow/index.html">
            
                
                    <a href="../C03-Gitflow/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Git工作流
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="C03-Gitflow/Gitflow.html">
            
                
                    <a href="../C03-Gitflow/Gitflow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        Gitflow
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="C03-Gitflow/AboutGit.html">
            
                
                    <a href="../C03-Gitflow/AboutGit.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        Git总结
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="C03-Gitflow/ProjectDirectory.html">
            
                
                    <a href="../C03-Gitflow/ProjectDirectory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        工程目录
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="C03-Gitflow/DebugMethod.html">
            
                
                    <a href="../C03-Gitflow/DebugMethod.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        调试方法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="C04-JWT/index.html">
            
                
                    <a href="../C04-JWT/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        JWT
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="C04-JWT/JWT.html">
            
                
                    <a href="../C04-JWT/JWT.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        JWT &amp; JWS &amp; JWE
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="C04-JWT/PythonLib.html">
            
                
                    <a href="../C04-JWT/PythonLib.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        PythonLib
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="C04-JWT/Implement.html">
            
                
                    <a href="../C04-JWT/Implement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        实施方案
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="C04-JWT/Forbbiden.html">
            
                
                    <a href="../C04-JWT/Forbbiden.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        禁用问题
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="C05-OSS/index.html">
            
                
                    <a href="../C05-OSS/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        对象存储
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="C05-OSS/Qiniu.html">
            
                
                    <a href="../C05-OSS/Qiniu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        七牛云存储
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="C05-OSS/CDN.html">
            
                
                    <a href="../C05-OSS/CDN.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        CDN
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="C06-Cache/index.html">
            
                
                    <a href="../C06-Cache/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        缓存
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="C06-Cache/CacheArchitecture.html">
            
                
                    <a href="../C06-Cache/CacheArchitecture.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        缓存的架构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="C06-Cache/CacheData.html">
            
                
                    <a href="../C06-Cache/CacheData.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        缓存的数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="C06-Cache/CacheTTLAndEviction.html">
            
                
                    <a href="../C06-Cache/CacheTTLAndEviction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        缓存的有效期与淘汰策略
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="C06-Cache/CachePatterns.html">
            
                
                    <a href="../C06-Cache/CachePatterns.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        缓存模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="C06-Cache/CacheProblems.html">
            
                
                    <a href="../C06-Cache/CacheProblems.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        缓存问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="C06-Cache/ProjectCacheAndStorageDesign.html">
            
                
                    <a href="../C06-Cache/ProjectCacheAndStorageDesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        项目缓存与Redis持久存储设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="C06-Cache/ProjectCacheImplement.html">
            
                
                    <a href="../C06-Cache/ProjectCacheImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        项目缓存实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="C06-Cache/ProjectRedisStorageImplement.html">
            
                
                    <a href="../C06-Cache/ProjectRedisStorageImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        项目Redis持久存储实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="C07-APScheduler/index.html">
            
                
                    <a href="../C07-APScheduler/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        APScheduler
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="C07-APScheduler/APSchedulerTutorial.html">
            
                
                    <a href="../C07-APScheduler/APSchedulerTutorial.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        APScheduler使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="C07-APScheduler/FixStatistics.html">
            
                
                    <a href="../C07-APScheduler/FixStatistics.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        定时修正统计数据
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="C08-RPC/index.html">
            
                
                    <a href="../C08-RPC/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        RPC
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="C08-RPC/AboutRPC.html">
            
                
                    <a href="../C08-RPC/AboutRPC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        RPC简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="C08-RPC/gRPC.html">
            
                
                    <a href="../C08-RPC/gRPC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        gRPC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="C08-RPC/ProtocolBuffers.html">
            
                
                    <a href="../C08-RPC/ProtocolBuffers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        Protocol Buffers
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="C08-RPC/RecoSysIDL.html">
            
                
                    <a href="../C08-RPC/RecoSysIDL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        推荐系统接口定义
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="C08-RPC/Server.html">
            
                
                    <a href="../C08-RPC/Server.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        服务端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="C08-RPC/Client.html">
            
                
                    <a href="../C08-RPC/Client.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.7" data-path="C08-RPC/ToutiaoAPIViewImplement.html">
            
                
                    <a href="../C08-RPC/ToutiaoAPIViewImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.7.</b>
                        
                        头条首页新闻推荐接口编写
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" data-path="C09-IM/index.html">
            
                
                    <a href="../C09-IM/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        即时通信
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="C09-IM/AboutIM.html">
            
                
                    <a href="../C09-IM/AboutIM.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        即时通信简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="C09-IM/WebSocket.html">
            
                
                    <a href="../C09-IM/WebSocket.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                        WebSocket
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="C09-IM/SocketIO.html">
            
                
                    <a href="../C09-IM/SocketIO.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.3.</b>
                        
                        Socket.IO
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="C09-IM/Chat.html">
            
                
                    <a href="../C09-IM/Chat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.4.</b>
                        
                        头条聊天服务实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="C09-IM/MessagePush.html">
            
                
                    <a href="../C09-IM/MessagePush.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.5.</b>
                        
                        头条在线消息推送实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10" data-path="C10-Elasticsearch/index.html">
            
                
                    <a href="../C10-Elasticsearch/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        Elasticsearch
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.1" data-path="C10-Elasticsearch/Introduction.html">
            
                
                    <a href="../C10-Elasticsearch/Introduction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.1.</b>
                        
                        简介与原理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.2" data-path="C10-Elasticsearch/ConceptAndCluster.html">
            
                
                    <a href="../C10-Elasticsearch/ConceptAndCluster.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.2.</b>
                        
                        概念与集群
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.3" data-path="C10-Elasticsearch/AnalysisIK.html">
            
                
                    <a href="../C10-Elasticsearch/AnalysisIK.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.3.</b>
                        
                        IK中文分析器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.4" data-path="C10-Elasticsearch/IndexAndType.html">
            
                
                    <a href="../C10-Elasticsearch/IndexAndType.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.4.</b>
                        
                        索引与类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.5" data-path="C10-Elasticsearch/Document.html">
            
                
                    <a href="../C10-Elasticsearch/Document.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.5.</b>
                        
                        文档
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.6" data-path="C10-Elasticsearch/Logstash.html">
            
                
                    <a href="../C10-Elasticsearch/Logstash.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.6.</b>
                        
                        Logstash导入数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.7" data-path="C10-Elasticsearch/Query.html">
            
                
                    <a href="../C10-Elasticsearch/Query.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.7.</b>
                        
                        查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.8" data-path="C10-Elasticsearch/ToutiaoSearchImplement.html">
            
                
                    <a href="../C10-Elasticsearch/ToutiaoSearchImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.8.</b>
                        
                        头条全文检索实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.9" data-path="C10-Elasticsearch/Suggest.html">
            
                
                    <a href="../C10-Elasticsearch/Suggest.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.9.</b>
                        
                        suggest查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.10" data-path="C10-Elasticsearch/ToutiaoSuggestImplement.html">
            
                
                    <a href="../C10-Elasticsearch/ToutiaoSuggestImplement.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.10.</b>
                        
                        头条suggest查询实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="11" data-path="C11-Unittest.html">
            
                
                    <a href="../C11-Unittest.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                        单元测试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12" data-path="C12-Deployment/index.html">
            
                
                    <a href="../C12-Deployment/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.</b>
                        
                        部署相关
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="12.1" data-path="C12-Deployment/Gunicorn.html">
            
                
                    <a href="../C12-Deployment/Gunicorn.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.1.</b>
                        
                        Gunicorn
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="C12-Deployment/Supervisor.html">
            
                
                    <a href="../C12-Deployment/Supervisor.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.2.</b>
                        
                        Supervisor
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >课程简介</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x6570;&#x636E;&#x5E93;&#x7406;&#x8BBA;">&#x6570;&#x636E;&#x5E93;&#x7406;&#x8BBA;</h1>
<h2 id="1-&#x590D;&#x5236;&#x96C6;&#x4E0E;&#x5206;&#x5E03;&#x5F0F;">1. &#x590D;&#x5236;&#x96C6;&#x4E0E;&#x5206;&#x5E03;&#x5F0F;</h2>
<ul>
<li>&#x590D;&#x5236;&#x96C6;&#xFF08;<strong>Replication</strong>&#xFF09;<ul>
<li>&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x6570;&#x636E;&#x76F8;&#x540C;&#xFF0C;&#x8D77;&#x5230;&#x5907;&#x4EFD;&#x4F5C;&#x7528;</li>
<li>&#x9AD8;&#x53EF;&#x7528; High Available  HA</li>
</ul>
</li>
<li>&#x5206;&#x5E03;&#x5F0F;&#xFF08;<strong>Distribution</strong>&#xFF09;<ul>
<li>&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x6570;&#x636E;&#x4E0D;&#x540C;&#xFF0C;&#x5171;&#x540C;&#x7EC4;&#x6210;&#x5B8C;&#x6574;&#x7684;&#x6570;&#x636E;&#x96C6;&#x5408;</li>
<li>&#x901A;&#x5E38;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x88AB;&#x79F0;&#x4E3A;&#x4E00;&#x4E2A;&#x5206;&#x7247;&#xFF08;shard)</li>
<li>&#x9AD8;&#x541E;&#x5410; High Throughput</li>
</ul>
</li>
<li>&#x590D;&#x5236;&#x96C6;&#x4E0E;&#x5206;&#x5E03;&#x5F0F;&#x53EF;&#x4EE5;&#x5355;&#x72EC;&#x4F7F;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7EC4;&#x5408;&#x4F7F;&#x7528;&#xFF08;&#x5373;&#x6BCF;&#x4E2A;&#x5206;&#x7247;&#x90FD;&#x7EC4;&#x5EFA;&#x4E00;&#x4E2A;&#x590D;&#x5236;&#x96C6;&#xFF09;</li>
<li>&#x5173;&#x4E8E;&#x4E3B;&#xFF08;Master&#xFF09;&#x4ECE;&#xFF08;Slave&#xFF09;<ul>
<li>&#x8FD9;&#x4E2A;&#x6982;&#x5FF5;&#x662F;&#x4ECE;&#x4F7F;&#x7528;&#x7684;&#x89D2;&#x5EA6;&#x6765;&#x9610;&#x8FF0;&#x95EE;&#x9898;&#x7684;</li>
<li>&#x4E3B;&#x8282;&#x70B9; -&gt; &#x8868;&#x793A;&#x7A0B;&#x5E8F;&#x5728;&#x8FD9;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x6700;&#x5148;&#x66F4;&#x65B0;&#x6570;&#x636E;</li>
<li>&#x4ECE;&#x8282;&#x70B9; -&gt; &#x8868;&#x793A;&#x8FD9;&#x4E2A;&#x8282;&#x70B9;&#x7684;&#x6570;&#x636E;&#x662F;&#x8981;&#x901A;&#x8FC7;&#x590D;&#x5236;&#x4E3B;&#x8282;&#x70B9;&#x800C;&#x6765;</li>
<li>&#x590D;&#x5236;&#x96C6; &#x53EF;&#x9009; &#x4E3B;&#x4ECE;&#x3001;&#x4E3B;&#x4E3B;&#x3001;&#x4E3B;&#x4E3B;&#x4ECE;&#x4ECE;</li>
<li>&#x5206;&#x5E03;&#x5F0F; &#x6BCF;&#x4E2A;&#x5206;&#x7247;&#x90FD;&#x662F;&#x4E3B;&#xFF0C;&#x7EC4;&#x5408;&#x4F7F;&#x7528;&#x590D;&#x5236;&#x96C6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x590D;&#x5236;&#x96C6;&#x7684;&#x662F;&#x4ECE;</li>
</ul>
</li>
</ul>
<h2 id="2-mysql">2. MySQL</h2>
<h4 id="1&#xFF09;-&#x4E3B;&#x4ECE;&#x590D;&#x5236;">1&#xFF09; &#x4E3B;&#x4ECE;&#x590D;&#x5236;</h4>
<p>&#x590D;&#x5236;&#x5206;&#x6210;&#x4E09;&#x6B65;&#xFF1A;</p>
<ol>
<li>master&#x5C06;&#x6539;&#x53D8;&#x8BB0;&#x5F55;&#x5230;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;(binary log)&#x4E2D;&#xFF08;&#x8FD9;&#x4E9B;&#x8BB0;&#x5F55;&#x53EB;&#x505A;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;&#x4E8B;&#x4EF6;&#xFF0C;binary log events&#xFF09;&#xFF1B;</li>
<li>slave&#x5C06;master&#x7684;binary log events&#x62F7;&#x8D1D;&#x5230;&#x5B83;&#x7684;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;(relay log)&#xFF1B;</li>
<li>slave&#x91CD;&#x505A;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x4E2D;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x5C06;&#x6539;&#x53D8;&#x53CD;&#x6620;&#x5B83;&#x81EA;&#x5DF1;&#x7684;&#x6570;&#x636E;&#x3002;</li>
</ol>
<p>&#x4E0B;&#x56FE;&#x63CF;&#x8FF0;&#x4E86;&#x8FD9;&#x4E00;&#x8FC7;&#x7A0B;&#xFF1A;</p>
<p><img src="../images/mysql-master-slave.jpg" alt="&#x4E3B;&#x4ECE;&#x590D;&#x5236;"></p>
<p>&#x8BE5;&#x8FC7;&#x7A0B;&#x7684;&#x7B2C;&#x4E00;&#x90E8;&#x5206;&#x5C31;&#x662F;master&#x8BB0;&#x5F55;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;&#x3002;&#x5728;&#x6BCF;&#x4E2A;&#x4E8B;&#x52A1;&#x66F4;&#x65B0;&#x6570;&#x636E;&#x5B8C;&#x6210;&#x4E4B;&#x524D;&#xFF0C;master&#x5728;&#x4E8C;&#x65E5;&#x5FD7;&#x8BB0;&#x5F55;&#x8FD9;&#x4E9B;&#x6539;&#x53D8;&#x3002;MySQL&#x5C06;&#x4E8B;&#x52A1;&#x4E32;&#x884C;&#x7684;&#x5199;&#x5165;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;&#xFF0C;&#x5373;&#x4F7F;&#x4E8B;&#x52A1;&#x4E2D;&#x7684;&#x8BED;&#x53E5;&#x90FD;&#x662F;&#x4EA4;&#x53C9;&#x6267;&#x884C;&#x7684;&#x3002;&#x5728;&#x4E8B;&#x4EF6;&#x5199;&#x5165;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;&#x5B8C;&#x6210;&#x540E;&#xFF0C;master&#x901A;&#x77E5;&#x5B58;&#x50A8;&#x5F15;&#x64CE;&#x63D0;&#x4EA4;&#x4E8B;&#x52A1;&#x3002;</p>
<p>&#x4E0B;&#x4E00;&#x6B65;&#x5C31;&#x662F;slave&#x5C06;master&#x7684;binary log&#x62F7;&#x8D1D;&#x5230;&#x5B83;&#x81EA;&#x5DF1;&#x7684;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x3002;&#x9996;&#x5148;&#xFF0C;slave&#x5F00;&#x59CB;&#x4E00;&#x4E2A;&#x5DE5;&#x4F5C;&#x7EBF;&#x7A0B;&#x2014;&#x2014;I/O&#x7EBF;&#x7A0B;&#x3002;I/O&#x7EBF;&#x7A0B;&#x5728;master&#x4E0A;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x7684;&#x8FDE;&#x63A5;&#xFF0C;&#x7136;&#x540E;&#x5F00;&#x59CB;binlog dump process&#x3002;Binlog dump process&#x4ECE;master&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x65E5;&#x5FD7;&#x4E2D;&#x8BFB;&#x53D6;&#x4E8B;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x5DF2;&#x7ECF;&#x8DDF;&#x4E0A;master&#xFF0C;&#x5B83;&#x4F1A;&#x7761;&#x7720;&#x5E76;&#x7B49;&#x5F85;master&#x4EA7;&#x751F;&#x65B0;&#x7684;&#x4E8B;&#x4EF6;&#x3002;I/O&#x7EBF;&#x7A0B;&#x5C06;&#x8FD9;&#x4E9B;&#x4E8B;&#x4EF6;&#x5199;&#x5165;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x3002;</p>
<p>SQL slave thread&#x5904;&#x7406;&#x8BE5;&#x8FC7;&#x7A0B;&#x7684;&#x6700;&#x540E;&#x4E00;&#x6B65;&#x3002;SQL&#x7EBF;&#x7A0B;&#x4ECE;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x8BFB;&#x53D6;&#x4E8B;&#x4EF6;&#xFF0C;&#x66F4;&#x65B0;slave&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4F7F;&#x5176;&#x4E0E;master&#x4E2D;&#x7684;&#x6570;&#x636E;&#x4E00;&#x81F4;&#x3002;&#x53EA;&#x8981;&#x8BE5;&#x7EBF;&#x7A0B;&#x4E0E;I/O&#x7EBF;&#x7A0B;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#xFF0C;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x901A;&#x5E38;&#x4F1A;&#x4F4D;&#x4E8E;OS&#x7684;&#x7F13;&#x5B58;&#x4E2D;&#xFF0C;&#x6240;&#x4EE5;&#x4E2D;&#x7EE7;&#x65E5;&#x5FD7;&#x7684;&#x5F00;&#x9500;&#x5F88;&#x5C0F;&#x3002;</p>
<p>&#x6B64;&#x5916;&#xFF0C;&#x5728;master&#x4E2D;&#x4E5F;&#x6709;&#x4E00;&#x4E2A;&#x5DE5;&#x4F5C;&#x7EBF;&#x7A0B;&#xFF1A;&#x548C;&#x5176;&#x5B83;MySQL&#x7684;&#x8FDE;&#x63A5;&#x4E00;&#x6837;&#xFF0C;slave&#x5728;master&#x4E2D;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x8FDE;&#x63A5;&#x4E5F;&#x4F1A;&#x4F7F;&#x5F97;master&#x5F00;&#x59CB;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x3002;</p>
<p><strong>&#x5229;&#x7528;&#x4E3B;&#x4ECE;&#x5728;&#x8FBE;&#x5230;&#x9AD8;&#x53EF;&#x7528;&#x7684;&#x540C;&#x65F6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#x63D0;&#x4F9B;&#x541E;&#x5410;&#x91CF;&#x3002;</strong></p>
<h4 id="&#x601D;&#x8003;&#xFF1A;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#x5BF9;&#x4E8B;&#x52A1;&#x662F;&#x5426;&#x6709;&#x5F71;&#x54CD;&#xFF1F;">&#x601D;&#x8003;&#xFF1A;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#x5BF9;&#x4E8B;&#x52A1;&#x662F;&#x5426;&#x6709;&#x5F71;&#x54CD;&#xFF1F;</h4>
<blockquote>
<p>&#x5BF9;&#x4E8E;&#x5199;&#x64CD;&#x4F5C;&#x5305;&#x62EC;&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#x548C;&#x63D0;&#x4EA4;&#x6216;&#x56DE;&#x6EDA;&#x8981;&#x5728;&#x4E00;&#x53F0;&#x673A;&#x5668;&#x4E0A;&#x6267;&#x884C;&#xFF0C;&#x5206;&#x6563;&#x5230;&#x591A;&#x53F0;master&#x6267;&#x884C;&#x540E;&#x6570;&#x636E;&#x5E93;&#x539F;&#x751F;&#x7684;&#x5355;&#x673A;&#x4E8B;&#x52A1;&#x5C31;&#x5931;&#x6548;&#x4E86;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x4E8B;&#x52A1;&#x4E2D;&#x540C;&#x65F6;&#x5305;&#x542B;&#x8BFB;&#x5199;&#x64CD;&#x4F5C;&#xFF0C;&#x4E0E;&#x4E8B;&#x52A1;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x8BBE;&#x7F6E;&#x6709;&#x5173;&#xFF0C;&#x5982;&#x679C;&#x4E8B;&#x52A1;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x4E3A;read-uncommitted &#x6216;&#x8005; read-committed&#xFF0C;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#x6CA1;&#x5F71;&#x54CD;&#xFF0C;&#x5982;&#x679C;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x4E3A;repeatable-read&#x3001;serializable&#xFF0C;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#x5C31;&#x6709;&#x5F71;&#x54CD;&#xFF0C;&#x56E0;&#x4E3A;&#x5728;slave&#x4E0A;&#x4F1A;&#x770B;&#x5230;&#x65B0;&#x6570;&#x636E;&#xFF0C;&#x800C;&#x6B63;&#x5728;&#x4E8B;&#x52A1;&#x4E2D;&#x7684;master&#x770B;&#x4E0D;&#x5230;&#x65B0;&#x6570;&#x636E;&#x3002;</p>
</blockquote>
<h4 id="2&#xFF09;&#x5206;&#x5E93;&#x5206;&#x8868;&#xFF08;sharding&#xFF09;">2&#xFF09;&#x5206;&#x5E93;&#x5206;&#x8868;&#xFF08;sharding&#xFF09;</h4>
<h5 id="&#x5206;&#x5E93;&#x5206;&#x8868;&#x524D;&#x7684;&#x95EE;&#x9898;">&#x5206;&#x5E93;&#x5206;&#x8868;&#x524D;&#x7684;&#x95EE;&#x9898;</h5>
<p>&#x4EFB;&#x4F55;&#x95EE;&#x9898;&#x90FD;&#x662F;&#x592A;&#x5927;&#x6216;&#x8005;&#x592A;&#x5C0F;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x8FD9;&#x91CC;&#x9762;&#x5BF9;&#x7684;&#x6570;&#x636E;&#x91CF;&#x592A;&#x5927;&#x7684;&#x95EE;&#x9898;&#x3002;</p>
<ul>
<li><p>&#x7528;&#x6237;&#x8BF7;&#x6C42;&#x91CF;&#x592A;&#x5927;</p>
<p>&#x56E0;&#x4E3A;&#x5355;&#x670D;&#x52A1;&#x5668;TPS&#xFF0C;&#x5185;&#x5B58;&#xFF0C;IO&#x90FD;&#x662F;&#x6709;&#x9650;&#x7684;&#x3002; &#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;&#x5206;&#x6563;&#x8BF7;&#x6C42;&#x5230;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF1B; &#x5176;&#x5B9E;&#x7528;&#x6237;&#x8BF7;&#x6C42;&#x548C;&#x6267;&#x884C;&#x4E00;&#x4E2A;sql&#x67E5;&#x8BE2;&#x662F;&#x672C;&#x8D28;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x90FD;&#x662F;&#x8BF7;&#x6C42;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#xFF0C;&#x53EA;&#x662F;&#x7528;&#x6237;&#x8BF7;&#x6C42;&#x8FD8;&#x4F1A;&#x7ECF;&#x8FC7;&#x7F51;&#x5173;&#xFF0C;&#x8DEF;&#x7531;&#xFF0C;http&#x670D;&#x52A1;&#x5668;&#x7B49;&#x3002;</p>
</li>
<li><p>&#x5355;&#x5E93;&#x592A;&#x5927;</p>
<p>&#x5355;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x5904;&#x7406;&#x80FD;&#x529B;&#x6709;&#x9650;&#xFF1B;&#x5355;&#x5E93;&#x6240;&#x5728;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x78C1;&#x76D8;&#x7A7A;&#x95F4;&#x4E0D;&#x8DB3;&#xFF1B;&#x5355;&#x5E93;&#x4E0A;&#x64CD;&#x4F5C;&#x7684;IO&#x74F6;&#x9888; &#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;&#x5207;&#x5206;&#x6210;&#x66F4;&#x591A;&#x66F4;&#x5C0F;&#x7684;&#x5E93;</p>
</li>
<li><p>&#x5355;&#x8868;&#x592A;&#x5927;</p>
<p>CRUD&#x90FD;&#x6210;&#x95EE;&#x9898;&#xFF1B;&#x7D22;&#x5F15;&#x81A8;&#x80C0;&#xFF0C;&#x67E5;&#x8BE2;&#x8D85;&#x65F6; &#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;&#x5207;&#x5206;&#x6210;&#x591A;&#x4E2A;&#x6570;&#x636E;&#x96C6;&#x66F4;&#x5C0F;&#x7684;&#x8868;&#x3002;</p>
</li>
</ul>
<h5 id="&#x5206;&#x5E93;&#x5206;&#x8868;&#x7684;&#x65B9;&#x5F0F;&#x65B9;&#x6CD5;">&#x5206;&#x5E93;&#x5206;&#x8868;&#x7684;&#x65B9;&#x5F0F;&#x65B9;&#x6CD5;</h5>
<p>&#x4E00;&#x822C;&#x5C31;&#x662F;&#x5782;&#x76F4;&#x5207;&#x5206;&#x548C;&#x6C34;&#x5E73;&#x5207;&#x5206;&#xFF0C;&#x8FD9;&#x662F;&#x4E00;&#x79CD;&#x7ED3;&#x679C;&#x96C6;&#x63CF;&#x8FF0;&#x7684;&#x5207;&#x5206;&#x65B9;&#x5F0F;&#xFF0C;&#x662F;&#x7269;&#x7406;&#x7A7A;&#x95F4;&#x4E0A;&#x7684;&#x5207;&#x5206;&#x3002; &#x6211;&#x4EEC;&#x4ECE;&#x9762;&#x4E34;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x5F00;&#x59CB;&#x89E3;&#x51B3;&#xFF0C;&#x9610;&#x8FF0;&#xFF1A; &#x9996;&#x5148;&#x662F;&#x7528;&#x6237;&#x8BF7;&#x6C42;&#x91CF;&#x592A;&#x5927;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x5806;&#x673A;&#x5668;&#x641E;&#x5B9A;&#xFF08;&#x8FD9;&#x4E0D;&#x662F;&#x672C;&#x6587;&#x91CD;&#x70B9;&#xFF09;&#x3002;</p>
<p>&#x7136;&#x540E;&#x662F;&#x5355;&#x4E2A;&#x5E93;&#x592A;&#x5927;&#xFF0C;&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x8981;&#x770B;&#x662F;&#x56E0;&#x4E3A;&#x8868;&#x591A;&#x800C;&#x5BFC;&#x81F4;&#x6570;&#x636E;&#x591A;&#xFF0C;&#x8FD8;&#x662F;&#x56E0;&#x4E3A;&#x5355;&#x5F20;&#x8868;&#x91CC;&#x9762;&#x7684;&#x6570;&#x636E;&#x591A;&#x3002; &#x5982;&#x679C;&#x662F;&#x56E0;&#x4E3A;&#x8868;&#x591A;&#x800C;&#x6570;&#x636E;&#x591A;&#xFF0C;&#x4F7F;&#x7528;&#x5782;&#x76F4;&#x5207;&#x5206;&#xFF0C;&#x6839;&#x636E;&#x4E1A;&#x52A1;&#x5207;&#x5206;&#x6210;&#x4E0D;&#x540C;&#x7684;&#x5E93;&#x3002;</p>
<p>&#x5982;&#x679C;&#x662F;&#x56E0;&#x4E3A;&#x5355;&#x5F20;&#x8868;&#x7684;&#x6570;&#x636E;&#x91CF;&#x592A;&#x5927;&#xFF0C;&#x8FD9;&#x65F6;&#x8981;&#x7528;&#x6C34;&#x5E73;&#x5207;&#x5206;&#xFF0C;&#x5373;&#x628A;&#x8868;&#x7684;&#x6570;&#x636E;&#x6309;&#x67D0;&#x79CD;&#x89C4;&#x5219;&#x5207;&#x5206;&#x6210;&#x591A;&#x5F20;&#x8868;&#xFF0C;&#x751A;&#x81F3;&#x591A;&#x4E2A;&#x5E93;&#x4E0A;&#x7684;&#x591A;&#x5F20;&#x8868;&#x3002; <strong>&#x5206;&#x5E93;&#x5206;&#x8868;&#x7684;&#x987A;&#x5E8F;&#x5E94;&#x8BE5;&#x662F;&#x5148;&#x5782;&#x76F4;&#x5206;&#xFF0C;&#x540E;&#x6C34;&#x5E73;&#x5206;&#x3002;</strong> &#x56E0;&#x4E3A;&#x5782;&#x76F4;&#x5206;&#x66F4;&#x7B80;&#x5355;&#xFF0C;&#x66F4;&#x7B26;&#x5408;&#x6211;&#x4EEC;&#x5904;&#x7406;&#x73B0;&#x5B9E;&#x4E16;&#x754C;&#x95EE;&#x9898;&#x7684;&#x65B9;&#x5F0F;&#x3002;</p>
<h5 id="&#x5782;&#x76F4;&#x62C6;&#x5206;">&#x5782;&#x76F4;&#x62C6;&#x5206;</h5>
<ol>
<li><p>&#x5782;&#x76F4;&#x5206;&#x8868;</p>
<p>&#x4E5F;&#x5C31;&#x662F;&#x201C;&#x5927;&#x8868;&#x62C6;&#x5C0F;&#x8868;&#x201D;&#xFF0C;&#x57FA;&#x4E8E;&#x5217;&#x5B57;&#x6BB5;&#x8FDB;&#x884C;&#x7684;&#x3002;&#x4E00;&#x822C;&#x662F;&#x8868;&#x4E2D;&#x7684;&#x5B57;&#x6BB5;&#x8F83;&#x591A;&#xFF0C;&#x5C06;&#x4E0D;&#x5E38;&#x7528;&#x7684;&#xFF0C; &#x6570;&#x636E;&#x8F83;&#x5927;&#xFF0C;&#x957F;&#x5EA6;&#x8F83;&#x957F;&#xFF08;&#x6BD4;&#x5982;text&#x7C7B;&#x578B;&#x5B57;&#x6BB5;&#xFF09;&#x7684;&#x62C6;&#x5206;&#x5230;&#x201C;&#x6269;&#x5C55;&#x8868;&#x201C;&#x3002; &#x4E00;&#x822C;&#x662F;&#x9488;&#x5BF9;&#x90A3;&#x79CD;&#x51E0;&#x767E;&#x5217;&#x7684;&#x5927;&#x8868;&#xFF0C;&#x4E5F;&#x907F;&#x514D;&#x67E5;&#x8BE2;&#x65F6;&#xFF0C;&#x6570;&#x636E;&#x91CF;&#x592A;&#x5927;&#x9020;&#x6210;&#x7684;&#x201C;&#x8DE8;&#x9875;&#x201D;&#x95EE;&#x9898;&#x3002;</p>
</li>
<li><p>&#x5782;&#x76F4;&#x5206;&#x5E93;</p>
<p>&#x5782;&#x76F4;&#x5206;&#x5E93;&#x9488;&#x5BF9;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x4E0D;&#x540C;&#x4E1A;&#x52A1;&#x8FDB;&#x884C;&#x62C6;&#x5206;&#xFF0C;&#x6BD4;&#x5982;&#x7528;&#x6237;User&#x4E00;&#x4E2A;&#x5E93;&#xFF0C;&#x5546;&#x54C1;Producet&#x4E00;&#x4E2A;&#x5E93;&#xFF0C;&#x8BA2;&#x5355;Order&#x4E00;&#x4E2A;&#x5E93;&#x3002; &#x5207;&#x5206;&#x540E;&#xFF0C;&#x8981;&#x653E;&#x5728;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x3002;&#x4E3A;&#x4EC0;&#x4E48;&#xFF1F; &#x6211;&#x4EEC;&#x60F3;&#x8C61;&#x4E00;&#x4E0B;&#xFF0C;&#x4E00;&#x4E2A;&#x8D2D;&#x7269;&#x7F51;&#x7AD9;&#x5BF9;&#x5916;&#x63D0;&#x4F9B;&#x670D;&#x52A1;&#xFF0C;&#x4F1A;&#x6709;&#x7528;&#x6237;&#xFF0C;&#x5546;&#x54C1;&#xFF0C;&#x8BA2;&#x5355;&#x7B49;&#x7684;CRUD&#x3002;&#x6CA1;&#x62C6;&#x5206;&#x4E4B;&#x524D;&#xFF0C; &#x5168;&#x90E8;&#x90FD;&#x662F;&#x843D;&#x5230;&#x5355;&#x4E00;&#x7684;&#x5E93;&#x4E0A;&#x7684;&#xFF0C;&#x8FD9;&#x4F1A;&#x8BA9;&#x6570;&#x636E;&#x5E93;&#x7684;&#x5355;&#x5E93;&#x5904;&#x7406;&#x80FD;&#x529B;&#x6210;&#x4E3A;&#x74F6;&#x9888;&#x3002;&#x6309;&#x5782;&#x76F4;&#x5206;&#x5E93;&#x540E;&#xFF0C;&#x5982;&#x679C;&#x8FD8;&#x662F;&#x653E;&#x5728;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF0C; &#x968F;&#x7740;&#x7528;&#x6237;&#x91CF;&#x589E;&#x5927;&#xFF0C;&#x8FD9;&#x4F1A;&#x8BA9;&#x5355;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x7684;&#x5904;&#x7406;&#x80FD;&#x529B;&#x6210;&#x4E3A;&#x74F6;&#x9888;&#xFF0C;&#x8FD8;&#x6709;&#x5355;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x7684;&#x78C1;&#x76D8;&#x7A7A;&#x95F4;&#xFF0C;&#x5185;&#x5B58;&#xFF0C;tps&#x7B49;&#x975E;&#x5E38;&#x5403;&#x7D27;&#x3002; &#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x8981;&#x62C6;&#x5206;&#x5230;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF0C;&#x8FD9;&#x6837;&#x4E0A;&#x9762;&#x7684;&#x95EE;&#x9898;&#x90FD;&#x89E3;&#x51B3;&#x4E86;&#xFF0C;&#x4EE5;&#x540E;&#x4E5F;&#x4E0D;&#x4F1A;&#x9762;&#x5BF9;&#x5355;&#x673A;&#x8D44;&#x6E90;&#x95EE;&#x9898;&#x3002;</p>
<p>&#x6570;&#x636E;&#x5E93;&#x4E1A;&#x52A1;&#x5C42;&#x9762;&#x7684;&#x62C6;&#x5206;&#xFF0C;&#x548C;&#x670D;&#x52A1;&#x7684;&#x201C;&#x6CBB;&#x7406;&#x201D;&#xFF0C;&#x201C;&#x964D;&#x7EA7;&#x201D;&#x673A;&#x5236;&#x7C7B;&#x4F3C;&#xFF0C;&#x4E5F;&#x80FD;&#x5BF9;&#x4E0D;&#x540C;&#x4E1A;&#x52A1;&#x7684;&#x6570;&#x636E;&#x5206;&#x522B;&#x7684;&#x8FDB;&#x884C;&#x7BA1;&#x7406;&#xFF0C;&#x7EF4;&#x62A4;&#xFF0C;&#x76D1;&#x63A7;&#xFF0C;&#x6269;&#x5C55;&#x7B49;&#x3002; &#x6570;&#x636E;&#x5E93;&#x5F80;&#x5F80;&#x6700;&#x5BB9;&#x6613;&#x6210;&#x4E3A;&#x5E94;&#x7528;&#x7CFB;&#x7EDF;&#x7684;&#x74F6;&#x9888;&#xFF0C;&#x800C;&#x6570;&#x636E;&#x5E93;&#x672C;&#x8EAB;&#x5C5E;&#x4E8E;&#x201C;&#x6709;&#x72B6;&#x6001;&#x201D;&#x7684;&#xFF0C;&#x76F8;&#x5BF9;&#x4E8E;Web&#x548C;&#x5E94;&#x7528;&#x670D;&#x52A1;&#x5668;&#x6765;&#x8BB2;&#xFF0C;&#x662F;&#x6BD4;&#x8F83;&#x96BE;&#x5B9E;&#x73B0;&#x201C;&#x6A2A;&#x5411;&#x6269;&#x5C55;&#x201D;&#x7684;&#x3002; &#x6570;&#x636E;&#x5E93;&#x7684;&#x8FDE;&#x63A5;&#x8D44;&#x6E90;&#x6BD4;&#x8F83;&#x5B9D;&#x8D35;&#x4E14;&#x5355;&#x673A;&#x5904;&#x7406;&#x80FD;&#x529B;&#x4E5F;&#x6709;&#x9650;&#xFF0C;&#x5728;&#x9AD8;&#x5E76;&#x53D1;&#x573A;&#x666F;&#x4E0B;&#xFF0C;&#x5782;&#x76F4;&#x5206;&#x5E93;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x4E0A;&#x80FD;&#x591F;&#x7A81;&#x7834;IO&#x3001;&#x8FDE;&#x63A5;&#x6570;&#x53CA;&#x5355;&#x673A;&#x786C;&#x4EF6;&#x8D44;&#x6E90;&#x7684;&#x74F6;&#x9888;&#x3002;</p>
</li>
</ol>
<h5 id="&#x6C34;&#x5E73;&#x62C6;&#x5206;">&#x6C34;&#x5E73;&#x62C6;&#x5206;</h5>
<ol>
<li><p>&#x6C34;&#x5E73;&#x5206;&#x8868;</p>
<p>&#x9488;&#x5BF9;&#x6570;&#x636E;&#x91CF;&#x5DE8;&#x5927;&#x7684;&#x5355;&#x5F20;&#x8868;&#xFF08;&#x6BD4;&#x5982;&#x8BA2;&#x5355;&#x8868;&#xFF09;&#xFF0C;&#x6309;&#x7167;&#x67D0;&#x79CD;&#x89C4;&#x5219;&#xFF08;RANGE,HASH&#x53D6;&#x6A21;&#x7B49;&#xFF09;&#xFF0C;&#x5207;&#x5206;&#x5230;&#x591A;&#x5F20;&#x8868;&#x91CC;&#x9762;&#x53BB;&#x3002; &#x4F46;&#x662F;&#x8FD9;&#x4E9B;&#x8868;&#x8FD8;&#x662F;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x5E93;&#x4E2D;&#xFF0C;&#x6240;&#x4EE5;&#x5E93;&#x7EA7;&#x522B;&#x7684;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;&#x8FD8;&#x662F;&#x6709;IO&#x74F6;&#x9888;&#x3002;&#x4E0D;&#x5EFA;&#x8BAE;&#x91C7;&#x7528;&#x3002;</p>
</li>
<li><p>&#x6C34;&#x5E73;&#x5206;&#x5E93;&#x5206;&#x8868;</p>
<p>&#x5C06;&#x5355;&#x5F20;&#x8868;&#x7684;&#x6570;&#x636E;&#x5207;&#x5206;&#x5230;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x53BB;&#xFF0C;&#x6BCF;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x5177;&#x6709;&#x76F8;&#x5E94;&#x7684;&#x5E93;&#x4E0E;&#x8868;&#xFF0C;&#x53EA;&#x662F;&#x8868;&#x4E2D;&#x6570;&#x636E;&#x96C6;&#x5408;&#x4E0D;&#x540C;&#x3002; &#x6C34;&#x5E73;&#x5206;&#x5E93;&#x5206;&#x8868;&#x80FD;&#x591F;&#x6709;&#x6548;&#x7684;&#x7F13;&#x89E3;&#x5355;&#x673A;&#x548C;&#x5355;&#x5E93;&#x7684;&#x6027;&#x80FD;&#x74F6;&#x9888;&#x548C;&#x538B;&#x529B;&#xFF0C;&#x7A81;&#x7834;IO&#x3001;&#x8FDE;&#x63A5;&#x6570;&#x3001;&#x786C;&#x4EF6;&#x8D44;&#x6E90;&#x7B49;&#x7684;&#x74F6;&#x9888;&#x3002;</p>
</li>
<li><p>&#x6C34;&#x5E73;&#x5206;&#x5E93;&#x5206;&#x8868;&#x5207;&#x5206;&#x89C4;&#x5219;</p>
</li>
<li><ol>
<li><p>RANGE</p>
<p>&#x4ECE;0&#x5230;10000&#x4E00;&#x4E2A;&#x8868;&#xFF0C;10001&#x5230;20000&#x4E00;&#x4E2A;&#x8868;&#xFF1B;</p>
</li>
<li><p>HASH&#x53D6;&#x6A21;   &#x79BB;&#x6563;&#x5316;   </p>
<p>&#x4E00;&#x4E2A;&#x5546;&#x573A;&#x7CFB;&#x7EDF;&#xFF0C;&#x4E00;&#x822C;&#x90FD;&#x662F;&#x5C06;&#x7528;&#x6237;&#xFF0C;&#x8BA2;&#x5355;&#x4F5C;&#x4E3A;&#x4E3B;&#x8868;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x548C;&#x5B83;&#x4EEC;&#x76F8;&#x5173;&#x7684;&#x4F5C;&#x4E3A;&#x9644;&#x8868;&#xFF0C;&#x8FD9;&#x6837;&#x4E0D;&#x4F1A;&#x9020;&#x6210;&#x8DE8;&#x5E93;&#x4E8B;&#x52A1;&#x4E4B;&#x7C7B;&#x7684;&#x95EE;&#x9898;&#x3002; &#x53D6;&#x7528;&#x6237;id&#xFF0C;&#x7136;&#x540E;hash&#x53D6;&#x6A21;&#xFF0C;&#x5206;&#x914D;&#x5230;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x5E93;&#x4E0A;&#x3002;</p>
</li>
<li><p>&#x5730;&#x7406;&#x533A;&#x57DF;</p>
<p>&#x6BD4;&#x5982;&#x6309;&#x7167;&#x534E;&#x4E1C;&#xFF0C;&#x534E;&#x5357;&#xFF0C;&#x534E;&#x5317;&#x8FD9;&#x6837;&#x6765;&#x533A;&#x5206;&#x4E1A;&#x52A1;&#xFF0C;&#x4E03;&#x725B;&#x4E91;&#x5E94;&#x8BE5;&#x5C31;&#x662F;&#x5982;&#x6B64;&#x3002;</p>
</li>
<li><p>&#x65F6;&#x95F4;</p>
<p>&#x6309;&#x7167;&#x65F6;&#x95F4;&#x5207;&#x5206;&#xFF0C;&#x5C31;&#x662F;&#x5C06;6&#x4E2A;&#x6708;&#x524D;&#xFF0C;&#x751A;&#x81F3;&#x4E00;&#x5E74;&#x524D;&#x7684;&#x6570;&#x636E;&#x5207;&#x51FA;&#x53BB;&#x653E;&#x5230;&#x53E6;&#x5916;&#x7684;&#x4E00;&#x5F20;&#x8868;&#xFF0C;&#x56E0;&#x4E3A;&#x968F;&#x7740;&#x65F6;&#x95F4;&#x6D41;&#x901D;&#xFF0C;&#x8FD9;&#x4E9B;&#x8868;&#x7684;&#x6570;&#x636E; &#x88AB;&#x67E5;&#x8BE2;&#x7684;&#x6982;&#x7387;&#x53D8;&#x5C0F;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x5FC5;&#x8981;&#x548C;&#x201C;&#x70ED;&#x6570;&#x636E;&#x201D;&#x653E;&#x5728;&#x4E00;&#x8D77;&#xFF0C;&#x8FD9;&#x4E2A;&#x4E5F;&#x662F;&#x201C;&#x51B7;&#x70ED;&#x6570;&#x636E;&#x5206;&#x79BB;&#x201D;&#x3002;</p>
</li>
</ol>
</li>
</ol>
<h5 id="&#x5206;&#x5E93;&#x5206;&#x8868;&#x540E;&#x9762;&#x4E34;&#x7684;&#x95EE;&#x9898;">&#x5206;&#x5E93;&#x5206;&#x8868;&#x540E;&#x9762;&#x4E34;&#x7684;&#x95EE;&#x9898;</h5>
<ul>
<li><p>&#x4E8B;&#x52A1;&#x652F;&#x6301;</p>
<p>&#x5206;&#x5E93;&#x5206;&#x8868;&#x540E;&#xFF0C;&#x5C31;&#x6210;&#x4E86;&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x4E86;&#x3002;&#x5982;&#x679C;&#x4F9D;&#x8D56;&#x6570;&#x636E;&#x5E93;&#x672C;&#x8EAB;&#x7684;&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x529F;&#x80FD;&#x53BB;&#x6267;&#x884C;&#x4E8B;&#x52A1;&#xFF0C;&#x5C06;&#x4ED8;&#x51FA;&#x9AD8;&#x6602;&#x7684;&#x6027;&#x80FD;&#x4EE3;&#x4EF7;&#xFF1B; &#x5982;&#x679C;&#x7531;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x53BB;&#x534F;&#x52A9;&#x63A7;&#x5236;&#xFF0C;&#x5F62;&#x6210;&#x7A0B;&#x5E8F;&#x903B;&#x8F91;&#x4E0A;&#x7684;&#x4E8B;&#x52A1;&#xFF0C;&#x53C8;&#x4F1A;&#x9020;&#x6210;&#x7F16;&#x7A0B;&#x65B9;&#x9762;&#x7684;&#x8D1F;&#x62C5;&#x3002;</p>
</li>
<li><p>&#x591A;&#x5E93;&#x7ED3;&#x679C;&#x96C6;&#x5408;&#x5E76;&#xFF08;group by&#xFF0C;order by&#xFF09;</p>
</li>
<li><p>&#x8DE8;&#x5E93;join</p>
<p>&#x5206;&#x5E93;&#x5206;&#x8868;&#x540E;&#x8868;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x8054;&#x64CD;&#x4F5C;&#x5C06;&#x53D7;&#x5230;&#x9650;&#x5236;&#xFF0C;&#x6211;&#x4EEC;&#x65E0;&#x6CD5;join&#x4F4D;&#x4E8E;&#x4E0D;&#x540C;&#x5206;&#x5E93;&#x7684;&#x8868;&#xFF0C;&#x4E5F;&#x65E0;&#x6CD5;join&#x5206;&#x8868;&#x7C92;&#x5EA6;&#x4E0D;&#x540C;&#x7684;&#x8868;&#xFF0C; &#x7ED3;&#x679C;&#x539F;&#x672C;&#x4E00;&#x6B21;&#x67E5;&#x8BE2;&#x80FD;&#x591F;&#x5B8C;&#x6210;&#x7684;&#x4E1A;&#x52A1;&#xFF0C;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x591A;&#x6B21;&#x67E5;&#x8BE2;&#x624D;&#x80FD;&#x5B8C;&#x6210;&#x3002; &#x7C97;&#x7565;&#x7684;&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A; &#x5168;&#x5C40;&#x8868;&#xFF1A;&#x57FA;&#x7840;&#x6570;&#x636E;&#xFF0C;&#x6240;&#x6709;&#x5E93;&#x90FD;&#x62F7;&#x8D1D;&#x4E00;&#x4EFD;&#x3002; &#x5B57;&#x6BB5;&#x5197;&#x4F59;&#xFF1A;&#x8FD9;&#x6837;&#x6709;&#x4E9B;&#x5B57;&#x6BB5;&#x5C31;&#x4E0D;&#x7528;join&#x53BB;&#x67E5;&#x8BE2;&#x4E86;&#x3002; &#x7CFB;&#x7EDF;&#x5C42;&#x7EC4;&#x88C5;&#xFF1A;&#x5206;&#x522B;&#x67E5;&#x8BE2;&#x51FA;&#x6240;&#x6709;&#xFF0C;&#x7136;&#x540E;&#x7EC4;&#x88C5;&#x8D77;&#x6765;&#xFF0C;&#x8F83;&#x590D;&#x6742;&#x3002;</p>
</li>
</ul>
<h5 id="&#x5206;&#x5E93;&#x5206;&#x8868;&#x65B9;&#x6848;&#x4EA7;&#x54C1;">&#x5206;&#x5E93;&#x5206;&#x8868;&#x65B9;&#x6848;&#x4EA7;&#x54C1;</h5>
<p>&#x76EE;&#x524D;&#x5E02;&#x9762;&#x4E0A;&#x7684;&#x5206;&#x5E93;&#x5206;&#x8868;&#x4E2D;&#x95F4;&#x4EF6;&#x76F8;&#x5BF9;&#x8F83;&#x591A;&#xFF0C;&#x5176;&#x4E2D;&#x57FA;&#x4E8E;&#x4EE3;&#x7406;&#x65B9;&#x5F0F;&#x7684;&#x6709;MySQL Proxy&#x548C;Amoeba&#xFF0C; &#x57FA;&#x4E8E;Hibernate&#x6846;&#x67B6;&#x7684;&#x662F;Hibernate Shards&#xFF0C;&#x57FA;&#x4E8E;jdbc&#x7684;&#x6709;&#x5F53;&#x5F53;sharding-jdbc&#xFF0C; &#x57FA;&#x4E8E;mybatis&#x7684;&#x7C7B;&#x4F3C;maven&#x63D2;&#x4EF6;&#x5F0F;&#x7684;&#x6709;&#x8611;&#x83C7;&#x8857;&#x7684;&#x8611;&#x83C7;&#x8857;TSharding&#xFF0C; &#x901A;&#x8FC7;&#x91CD;&#x5199;spring&#x7684;ibatis template&#x7C7B;&#x7684;Cobar Client&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x5927;&#x516C;&#x53F8;&#x7684;&#x5F00;&#x6E90;&#x4EA7;&#x54C1;&#xFF1A;</p>
<p><img src="../images/mysql-sharding.png" alt="&#x5206;&#x5E93;&#x5206;&#x8868;"></p>
<h3 id="3-&#x9ED1;&#x9A6C;&#x5934;&#x6761;&#x9879;&#x76EE;&#x5E94;&#x7528;">3 &#x9ED1;&#x9A6C;&#x5934;&#x6761;&#x9879;&#x76EE;&#x5E94;&#x7528;</h3>
<ul>
<li><p>&#x4E3B;&#x4ECE;</p>
</li>
<li><p>&#x5782;&#x76F4;&#x5206;&#x8868;</p>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-string">`user_basic`</span> (
  <span class="hljs-string">`user_id`</span> <span class="hljs-built_in">bigint</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> AUTO_INCREMENT <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7528;&#x6237;ID&apos;</span>,
  <span class="hljs-string">`account`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8D26;&#x53F7;&apos;</span>,
  <span class="hljs-string">`email`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x90AE;&#x7BB1;&apos;</span>,
  <span class="hljs-string">`status`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;1&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x72B6;&#x6001;&#xFF0C;&#x662F;&#x5426;&#x53EF;&#x7528;&#xFF0C;0-&#x4E0D;&#x53EF;&#x7528;&#xFF0C;1-&#x53EF;&#x7528;&apos;</span>,
  <span class="hljs-string">`mobile`</span> <span class="hljs-built_in">char</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x624B;&#x673A;&#x53F7;&apos;</span>,
  <span class="hljs-string">`password`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">93</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5BC6;&#x7801;&apos;</span>,
  <span class="hljs-string">`user_name`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">32</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>,
  <span class="hljs-string">`profile_photo`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">128</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5934;&#x50CF;&apos;</span>,
  <span class="hljs-string">`last_login`</span> datetime <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6700;&#x540E;&#x767B;&#x5F55;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`is_media`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x662F;&#x5426;&#x662F;&#x81EA;&#x5A92;&#x4F53;&#xFF0C;0-&#x4E0D;&#x662F;&#xFF0C;1-&#x662F;&apos;</span>,
  <span class="hljs-string">`is_verified`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x662F;&#x5426;&#x5B9E;&#x540D;&#x8BA4;&#x8BC1;&#xFF0C;0-&#x4E0D;&#x662F;&#xFF0C;1-&#x662F;&apos;</span>,
  <span class="hljs-string">`introduction`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">50</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7B80;&#x4ECB;&apos;</span>,
  <span class="hljs-string">`certificate`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">30</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8BA4;&#x8BC1;&apos;</span>,
  <span class="hljs-string">`article_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x53D1;&#x6587;&#x7AE0;&#x6570;&apos;</span>,
  <span class="hljs-string">`following_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5173;&#x6CE8;&#x7684;&#x4EBA;&#x6570;&apos;</span>,
  <span class="hljs-string">`fans_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x88AB;&#x5173;&#x6CE8;&#x7684;&#x4EBA;&#x6570;&apos;</span>,
  <span class="hljs-string">`like_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7D2F;&#x8BA1;&#x70B9;&#x8D5E;&#x4EBA;&#x6570;&apos;</span>,
  <span class="hljs-string">`read_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7D2F;&#x8BA1;&#x9605;&#x8BFB;&#x4EBA;&#x6570;&apos;</span>,
  PRIMARY <span class="hljs-keyword">KEY</span> (<span class="hljs-string">`user_id`</span>),
  <span class="hljs-keyword">UNIQUE</span> <span class="hljs-keyword">KEY</span> <span class="hljs-string">`mobile`</span> (<span class="hljs-string">`mobile`</span>),
  <span class="hljs-keyword">UNIQUE</span> <span class="hljs-keyword">KEY</span> <span class="hljs-string">`user_name`</span> (<span class="hljs-string">`user_name`</span>)
) <span class="hljs-keyword">ENGINE</span>=<span class="hljs-keyword">InnoDB</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CHARSET</span>=utf8 <span class="hljs-keyword">COMMENT</span>=<span class="hljs-string">&apos;&#x7528;&#x6237;&#x57FA;&#x672C;&#x4FE1;&#x606F;&#x8868;&apos;</span>;</span>

<span class="hljs-operator"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-string">`user_profile`</span> (
  <span class="hljs-string">`user_id`</span> <span class="hljs-built_in">bigint</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7528;&#x6237;ID&apos;</span>,
  <span class="hljs-string">`gender`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6027;&#x522B;&#xFF0C;0-&#x7537;&#xFF0C;1-&#x5973;&apos;</span>,
  <span class="hljs-string">`birthday`</span> <span class="hljs-built_in">date</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x751F;&#x65E5;&apos;</span>,
  <span class="hljs-string">`real_name`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">32</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x771F;&#x5B9E;&#x59D3;&#x540D;&apos;</span>,
  <span class="hljs-string">`id_number`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8EAB;&#x4EFD;&#x8BC1;&#x53F7;&apos;</span>,
  <span class="hljs-string">`id_card_front`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">128</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8EAB;&#x4EFD;&#x8BC1;&#x6B63;&#x9762;&apos;</span>,
  <span class="hljs-string">`id_card_back`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">128</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8EAB;&#x4EFD;&#x8BC1;&#x80CC;&#x9762;&apos;</span>,
  <span class="hljs-string">`id_card_handheld`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">128</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x624B;&#x6301;&#x8EAB;&#x4EFD;&#x8BC1;&apos;</span>,
  <span class="hljs-string">`create_time`</span> datetime <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x521B;&#x5EFA;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`update_time`</span> datetime <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">ON</span> <span class="hljs-keyword">UPDATE</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`register_media_time`</span> datetime <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6CE8;&#x518C;&#x81EA;&#x5A92;&#x4F53;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`area`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5730;&#x533A;&apos;</span>,
  <span class="hljs-string">`company`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x516C;&#x53F8;&apos;</span>,
  <span class="hljs-string">`career`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x804C;&#x4E1A;&apos;</span>,
  PRIMARY <span class="hljs-keyword">KEY</span> (<span class="hljs-string">`user_id`</span>)
) <span class="hljs-keyword">ENGINE</span>=<span class="hljs-keyword">InnoDB</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CHARSET</span>=utf8 <span class="hljs-keyword">COMMENT</span>=<span class="hljs-string">&apos;&#x7528;&#x6237;&#x8D44;&#x6599;&#x8868;&apos;</span>;</span>
</code></pre>
<pre><code class="lang-sql"><span class="hljs-operator"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-string">`news_article_basic`</span> (
  <span class="hljs-string">`article_id`</span> <span class="hljs-built_in">bigint</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> AUTO_INCREMENT <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6587;&#x7AE0;ID&apos;</span>,
  <span class="hljs-string">`user_id`</span> <span class="hljs-built_in">bigint</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7528;&#x6237;ID&apos;</span>,
  <span class="hljs-string">`channel_id`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x9891;&#x9053;ID&apos;</span>,
  <span class="hljs-string">`title`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">128</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6807;&#x9898;&apos;</span>,
  <span class="hljs-string">`cover`</span> <span class="hljs-keyword">json</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5C01;&#x9762;&apos;</span>,
  <span class="hljs-string">`is_advertising`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x662F;&#x5426;&#x6295;&#x653E;&#x5E7F;&#x544A;&#xFF0C;0-&#x4E0D;&#x6295;&#x653E;&#xFF0C;1-&#x6295;&#x653E;&apos;</span>,
  <span class="hljs-string">`create_time`</span> datetime <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x521B;&#x5EFA;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`update_time`</span> datetime <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">ON</span> <span class="hljs-keyword">UPDATE</span> <span class="hljs-keyword">CURRENT_TIMESTAMP</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`status`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x8D34;&#x6587;&#x72B6;&#x6001;&#xFF0C;0-&#x8349;&#x7A3F;&#xFF0C;1-&#x5F85;&#x5BA1;&#x6838;&#xFF0C;2-&#x5BA1;&#x6838;&#x901A;&#x8FC7;&#xFF0C;3-&#x5BA1;&#x6838;&#x5931;&#x8D25;&#xFF0C;4-&#x5DF2;&#x5220;&#x9664;&apos;</span>,
  <span class="hljs-string">`reviewer_id`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5BA1;&#x6838;&#x4EBA;&#x5458;ID&apos;</span>,
  <span class="hljs-string">`review_time`</span> datetime <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5BA1;&#x6838;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`delete_time`</span> datetime <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x5220;&#x9664;&#x65F6;&#x95F4;&apos;</span>,
  <span class="hljs-string">`reject_reason`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">200</span>) <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x9A73;&#x56DE;&#x539F;&#x56E0;&apos;</span>,
  <span class="hljs-string">`comment_count`</span> <span class="hljs-built_in">int</span>(<span class="hljs-number">11</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;0&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x7D2F;&#x8BA1;&#x8BC4;&#x8BBA;&#x6570;&apos;</span>,
  <span class="hljs-string">`allow_comment`</span> tinyint(<span class="hljs-number">1</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-string">&apos;1&apos;</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x662F;&#x5426;&#x5141;&#x8BB8;&#x8BC4;&#x8BBA;&#xFF0C;0-&#x4E0D;&#x5141;&#x8BB8;&#xFF0C;1-&#x5141;&#x8BB8;&apos;</span>,
  PRIMARY <span class="hljs-keyword">KEY</span> (<span class="hljs-string">`article_id`</span>),
  <span class="hljs-keyword">KEY</span> <span class="hljs-string">`user_id`</span> (<span class="hljs-string">`user_id`</span>),
  <span class="hljs-keyword">KEY</span> <span class="hljs-string">`article_status`</span> (<span class="hljs-string">`status`</span>)
) <span class="hljs-keyword">ENGINE</span>=<span class="hljs-keyword">InnoDB</span> <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CHARSET</span>=utf8 <span class="hljs-keyword">COMMENT</span>=<span class="hljs-string">&apos;&#x6587;&#x7AE0;&#x57FA;&#x672C;&#x4FE1;&#x606F;&#x8868;&apos;</span>;</span>

<span class="hljs-operator"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-string">`news_article_content`</span> (
  <span class="hljs-string">`article_id`</span> <span class="hljs-built_in">bigint</span>(<span class="hljs-number">20</span>) <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6587;&#x7AE0;ID&apos;</span>,
  <span class="hljs-string">`content`</span> longtext <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> <span class="hljs-keyword">COMMENT</span> <span class="hljs-string">&apos;&#x6587;&#x7AE0;&#x5185;&#x5BB9;&apos;</span>,
  PRIMARY <span class="hljs-keyword">KEY</span> (<span class="hljs-string">`article_id`</span>)
) <span class="hljs-keyword">ENGINE</span>=MyISAM <span class="hljs-keyword">DEFAULT</span> <span class="hljs-keyword">CHARSET</span>=utf8 <span class="hljs-keyword">COMMENT</span>=<span class="hljs-string">&apos;&#x6587;&#x7AE0;&#x5185;&#x5BB9;&#x8868;&apos;</span>;</span>
</code></pre>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../C02-Database/SQLAlchemyOperations.html" class="navigation navigation-prev " aria-label="Previous page: SQLAlchemy操作"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../C02-Database/DistributedID.html" class="navigation navigation-next " aria-label="Next page: 分布式ID"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
